package com.example.week7homework;

import android.content.Context;
 import android.database.sqlite.SQLiteDatabase;
 import android.database.sqlite.SQLiteDatabase.CursorFactory;
 import android.database.sqlite.SQLiteOpenHelper;
 
 public class StudentDBHelper extends SQLiteOpenHelper {
 
     // ����1���������ݿ�ͱ�������
     private static final String DATABASE_NAME = "student_db";
     private static final String TABLE_NAME = "student";
     private static final int DATABASE_VERSION=16;
 
     // ����2�����ع��췽��   �������ݿ⣬�汾Ϊ4
     public StudentDBHelper(Context context) {
         super(context, DATABASE_NAME, null, DATABASE_VERSION);
     }
     /**
      * ���ع��췽��
      * �������ܣ�context ���������Ļ���,�磺XXXActivity 
      * databaseName ���ݿ����� �� version ���ݿ�汾��          
      */
    public StudentDBHelper(Context context, String databaseName, int version) {
         super(context, databaseName, null, version);
     }
     
     //ֻ�������ݿ��һ�α�����ʱ��onCreate()�ᱻ���� ������ɴ��������ݵ����б�
     @Override
     public void onCreate(SQLiteDatabase db) {
        // ����3�����ݿ��Ĵ���
         String strSQL = "create table "+ TABLE_NAME
        		+" (sid integer primary key autoincrement,"
        		+" stu_no varchar(100), name varchar(100),"
        		+" clazz varchar(100), publish date)";
         db.execSQL(strSQL);
         String sql = "insert into " +TABLE_NAME
        		 +" values(null, '201601','������','16���ƿ�1��','2019-06-13')";
         db.execSQL(sql);
         sql = "insert into " +TABLE_NAME
        		 +" values(null, '201602','������','16���ƿ�1��','2019-06-13')";
         db.execSQL(sql);
         sql = "insert into " +TABLE_NAME
        		 +" values(null, '201603','����','17����ý1��','2019-06-14')";
         db.execSQL(sql);
         sql = "insert into " +TABLE_NAME
        		 +" values(null, '201604','�ټѶ�','16���ƿ�2��','2019-07-13')";
         db.execSQL(sql);
         sql = "insert into " +TABLE_NAME
        		 +" values(null, '201605','û����','16���ƿ�1��','2019-06-13')";
         db.execSQL(sql);
         sql = "insert into " +TABLE_NAME
        		 +" values(null, '201606','��Ҵ�','16���ƿ�2��','2019-05-13')";
         db.execSQL(sql);
         sql = "insert into " +TABLE_NAME
        		 +" values(null, '201607','ʱ����','16����ý1��','2019-06-13')";
         db.execSQL(sql);
         sql = "insert into " +TABLE_NAME
        		 +" values(null, '201608','����','16����ý1��','2019-06-13')";
         db.execSQL(sql);
         sql = "insert into " +TABLE_NAME
        		 +" values(null, '201609','Ѧ�Һ�','16����ý1��','2019-06-13')";
         db.execSQL(sql);
     }
     
     //�����ݿ�汾����ʱ���Ŵ�������һ��onUpgrade()��  ���ԶԱ�������������
     @Override
     public void onUpgrade(SQLiteDatabase arg0, int oldVersion, int newVersion) {
 
     }
 }